import sympy as sp
t = sp.Symbol('t')
s = t**2 + 2*t # 路程函数
time = t # 时间变量
v_avg = s / time # 平均速度函数

# 使用除法法则手动求导
u = s
v = time
deriv_manual = (sp.diff(u, t)*v - u*sp.diff(v, t)) / v**2
# 直接对平均速度函数求导
deriv_auto = sp.diff(v_avg, t)

print(f"手动计算 (s't - st')/t^2 = {deriv_manual.simplify()}")
print(f"自动计算 (s/t)' = {deriv_auto.simplify()}")
print(f"结果一致: {deriv_manual.simplify() == deriv_auto.simplify()}")